var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function o() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  KongMiaoDialog = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        e.btn_kongmiao_fabu.on(Laya.Event.CLICK, e, e.onDidClickFaBuAction),
        e.btn_kongmiao_tip_delete.on(
          Laya.Event.CLICK,
          e,
          e.onDidKongMiaoTipsDelete
        ),
        (e.list_kongmiao_msg.vScrollBarSkin = ""),
        (e.list_kongmiao_msg.selectEnable = !0),
        e.list_kongmiao_msg.on(Laya.Event.CLICK, e, e.onDidClickKMList),
        WebSocketService.addListener({
          caller: e,
          code: 1376,
          method: e.onLoadMySelfData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1359,
          method: e.onLoadKongMiaoDataFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1355,
          method: e.onLoadResultData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1361,
          method: e.onLoadResultData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1348,
          method: e.onLoadBaiShiOrZhaoTuReslut,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1358,
          method: e.onLoadDeleteAction,
        }),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showKongMiaoDialog = function (t) {
        return (
          null == this.kongmiaoVC &&
            ((this.kongmiaoVC = new e()), (this.kongmiaoVC.zOrder = 1001)),
          this.kongmiaoVC.popup(),
          (this.kongmiaoVC.jsonObj = t),
          (this.kongmiaoVC.dataArr = []),
          (this.kongmiaoVC.text_kongmiao.text = ""),
          (this.kongmiaoVC.label_kongmiao_desc.text = ""),
          (this.kongmiaoVC.btn_kongmiao_tip_delete.visible = !1),
          "拜师贴" == t.title
            ? ((this.kongmiaoVC.label_kongmiao_title.text = "拜师贴"),
              (this.kongmiaoVC.label_kongmiao_tip.text = "收徒申请列表："),
              WebSocketService.send({ c: 1376, d: { t: 0 } }))
            : "招徒贴" == t.title &&
              ((this.kongmiaoVC.label_kongmiao_title.text = "招徒贴"),
              (this.kongmiaoVC.label_kongmiao_tip.text = "拜师申请列表："),
              WebSocketService.send({ c: 1376, d: { t: 1 } })),
          (this.kongmiaoVC.list_kongmiao_msg.visible = !1),
          this.kongmiaoVC
        );
      }),
      (e.prototype.onDidClickFaBuAction = function (t) {
        if ("发布" == t.target.label) {
          var e = this.text_kongmiao.text;
          if (e.length <= 0) return void ToastView.toastView("请输入您的壮语");
          "拜师贴" == this.jsonObj.title
            ? WebSocketService.send({ c: 1348, d: { t: 0, c: e } })
            : "招徒贴" == this.jsonObj.title &&
              WebSocketService.send({ c: 1348, d: { t: 1, c: e } });
        } else
          "编辑" == t.target.label &&
            ((this.label_kongmiao_desc.visible = !1),
            (this.btn_kongmiao_tip_delete.visible = !1),
            (this.text_kongmiao.visible = !0),
            (this.btn_kongmiao_fabu.label = "发布"));
      }),
      (e.prototype.onLoadKongMiaoDataFn = function (t) {
        if (0 != t.code)
          return (
            ToastView.toastView(t.msg),
            void (this.list_kongmiao_msg.visible = !1)
          );
        (this.dataArr = t.list),
          t.list.length > 0 && (this.list_kongmiao_msg.visible = !0);
        var e,
          i = t.list;
        this.dataSource = [];
        for (var o = 0; o < i.length; o++) {
          var n = i[o],
            a = Utils.transform(i[o].sex, "roleSexType");
          (e = {
            item_name: { text: o + 1 + "." + n.name + " " + n.lvl + "级 " + a },
            id: n.id,
          }),
            this.dataSource.push(e);
        }
        this.list_kongmiao_msg.array = this.dataSource;
      }),
      (e.prototype.onLoadMySelfData = function (t) {
        0 == t.code &&
          ((this.label_kongmiao_desc.visible = !1),
          (this.text_kongmiao.visible = !0),
          (this.btn_kongmiao_tip_delete.visible = !1),
          (this.btn_kongmiao_fabu.label = "发布"),
          t.data
            ? ((this.text_kongmiao.text = t.data.content),
              this.text_kongmiao.text.length > 0 &&
                ((this.label_kongmiao_desc.visible = !0),
                (this.label_kongmiao_desc.text = this.text_kongmiao.text),
                (this.text_kongmiao.visible = !1),
                (this.btn_kongmiao_tip_delete.visible = !0),
                (this.btn_kongmiao_fabu.label = "编辑")),
              "拜师贴" == this.jsonObj.title
                ? WebSocketService.send({ c: 1359, d: { t: 0, pageNum: 0 } })
                : "招徒贴" == this.jsonObj.title &&
                  WebSocketService.send({ c: 1359, d: { t: 1, pageNum: 0 } }))
            : (this.text_kongmiao.text = ""));
      }),
      (e.prototype.onDidClickKMList = function (t) {
        if ("" != t.target.name) {
          var e = this.list_kongmiao_msg.selectedItem;
          "招徒贴" == this.jsonObj.title
            ? "item_jujue" == t.target.name
              ? WebSocketService.send({ c: 1361, d: { id: e.id, t: 0 } })
              : "item_tongyi" == t.target.name &&
                WebSocketService.send({ c: 1355, d: { id: e.id, t: 1 } })
            : "拜师贴" == this.jsonObj.title &&
              ("item_jujue" == t.target.name
                ? WebSocketService.send({ c: 1361, d: { id: e.id, t: 1 } })
                : "item_tongyi" == t.target.name &&
                  WebSocketService.send({ c: 1355, d: { id: e.id, t: 0 } }));
        }
      }),
      (e.prototype.onLoadResultData = function (t) {
        ToastView.toastView(t.msg),
          "已经成为师徒" != t.msg &&
            ("拜师贴" == this.jsonObj.title
              ? WebSocketService.send({ c: 1359, d: { t: 0, pageNum: 0 } })
              : "招徒贴" == this.jsonObj.title &&
                WebSocketService.send({ c: 1359, d: { t: 1, pageNum: 0 } }));
      }),
      (e.prototype.onLoadBaiShiOrZhaoTuReslut = function (t) {
        ToastView.toastView(t.msg),
          0 == t.code &&
            ((this.label_kongmiao_desc.visible = !0),
            (this.text_kongmiao.visible = !1),
            (this.label_kongmiao_desc.text = this.text_kongmiao.text),
            (this.btn_kongmiao_tip_delete.visible = !0),
            (this.btn_kongmiao_fabu.label = "编辑"));
      }),
      (e.prototype.onDidKongMiaoTipsDelete = function () {
        "拜师贴" == this.jsonObj.title
          ? WebSocketService.send({ c: 1358, d: { t: 0 } })
          : "招徒贴" == this.jsonObj.title &&
            WebSocketService.send({ c: 1358, d: { t: 1 } });
      }),
      (e.prototype.onLoadDeleteAction = function () {
        (this.btn_kongmiao_fabu.label = "编辑"),
          (this.btn_kongmiao_tip_delete.visible = !0),
          "拜师贴" == this.jsonObj.title
            ? WebSocketService.send({ c: 1376, d: { t: 0 } })
            : "招徒贴" == this.jsonObj.title &&
              WebSocketService.send({ c: 1376, d: { t: 1 } });
      }),
      e
    );
  })(ui.SubSquareController.KongMiaoDialogUI);
